package main

import (
	"fmt"
	"manygo/doconfig"
	"manygo/doweb"
	"manygo/mytools"
	// "runtime"
	"strings"
)

func main() {
	fmt.Println("start,loading...if no message,please Enter~")
	// rt := runtime.NumCPU()
	// fmt.Println("当前CPU为" + mytools.Int2String(rt) + "核")
	// fmt.Println("")
	// runtime.GOMAXPROCS(rt)
	initInput()
	if v, ok := doconfig.Config["ismaster"]; ok && v == "1" {
		doweb.MasterStart()

	} else {
		doweb.ClientStart()
	}

}
func initInput() {
	if !doweb.StartInit() {
		v := mytools.MyInput("Is master?[y/q/xxx.xxx.xxx.xxx]")
		if strings.ToUpper(v) == "Y" || strings.Trim(v, " ") == "" {
			doconfig.Config["ismaster"] = "1"

		} else if strings.ToUpper(v) == "Q" {
			mytools.MYClose(1)
		} else {
			doconfig.Config["masterip"] = v
		}
	} else {

		v := mytools.MyInput("Is connect local?[y/q/xxx.xxx.xxx.xxx]")
		if strings.ToUpper(v) == "Y" || strings.Trim(v, " ") == "" {
			doconfig.Config["ismaster"] = "0"
			doconfig.Config["masterip"] = "127.0.0.1"

		} else if strings.ToUpper(v) == "Q" {
			mytools.MYClose(1)
		} else {
			doconfig.Config["masterip"] = v
		}

	}

}
